//window.localStorage.isWeiXin
import cTitle from "components/title";
import inputList from "components/input_list";
import diyorm from "components/new_diyform";
import {
  Toast
} from "vant";
import Fun from '../../fun';
export default {
  //name: 'login',
  data() {
    return {
      registerShow: false,
      readonly: false,
      uniacid: '',
      form: {
        name: '',
        sex: 0,
        birthday: "",
        detailedAddress: '',
        dataTime: '请选择',
        accountNumber: '', //账号
        password: '', //密码
        text: '', //文本
        invite_code: '',
        address: '',
        login_checked: false, //协议是否勾选按钮
        field: '', //自定义固定字段
        nickname: '', //昵称
        fathername: '', //父亲姓名
        mothername: '', //母亲姓名
        klr_type: '',//1二维码A区 2二维码B区
      },
      fileList: [],
      pageType: "register",
      message: '',
      districtName: '', //地址
      district: district,
      sexShow: false, //性别选择弹窗
      birthdayShow: false, //生日选择弹窗
      showAdd: false, //地区选择弹窗
      dropDownBoxShow: false, //下拉框弹窗
      dateTimeShow: false, //日期时间弹窗
      inputShowList: {}, //组件输入框是否显示
      fixedDiyField: '', //自定义字段(固定)
      invite: '', //邀请码信息
      diyform: '', //自定义表单
      registerBasicInfo: {},
      nameOfTheMall: '', //商城名称
      userProtocol: '', //用户协议
      diyField: '', //自定义字段
      diyStatus: 0, //是否存在自定义表单
      changeNickname: false, //是否可以更改昵称
      changePicture: false, //是否可以更改头像
      member_id: '',
      form_id: "",
      fileList: [{
        url: "",
        isImage: true
      }], //头像图片
      orderLocationObj: {
        positioning_success: 0,
        register_province: "",
        register_city: ""
      },
      sexLIst: [{ //性别选择列表
        value: "男",
        url: require('@/assets/images/sex_man.png'),
        checkedUrl: require('@/assets/images/checked_sex_man.png'),
        checked: false
      }, {
        value: "女",
        url: require('@/assets/images/sex_girl.png'),
        checkedUrl: require('@/assets/images/checked_sex_girl.png'),
        checked: false
      }],
      dataList: '', //注册页数据
      minDate: new Date(1900, 0, 1),
      maxDate: new Date(2032, 12, 0),
      currentDate: new Date(),
      openPlatformAgreement: false,
      popoverProtocolContent: '',
      platformAgreement:'',//平台协议
      fixedFieldModification:false, //固定字段是否可只读,
      registerNotice: '',
      newIdcardNum: '',
      klr_type: '',
      recomandId: '',//推荐人id
      niuMid: '',//换牛二期-接点人ID-路径参数
      // ewcodeShow: false,
      // selectedOption: 'A区', // 初始选择的值
      // options: [
      //   { value: 'A区', label: 'A区' },
      //   { value: 'B区', label: 'B区' }
      // ]
      recomandMobile: '',//牛牛商城-89-推荐人手机号
      // recomandIdNiu: '',//牛牛商城-89-推荐人id
      jiedianMobile: '',//牛牛商城-89-接点人手机号
      niuniuRegisterPop: false,//牛牛商城-89-注册提交确定弹窗
      niuJiedianMobileinput: false,//牛牛商城-89-接点人手机号是否可编辑
      jiedianSearchId: '',//牛牛商城-89-接点人手机号查询id
      jiedianSearchNum: '',//牛牛商城-89-接点人手机号查询num
      jiedianInputId: '',//牛牛商城-89-接点人手机号id
      jiedianMobileAuto: '',//牛牛商城-89-自动接点人手机号
      openQuPickerShow: false,//十佳合--选区--弹窗
      quPickerSelected: '', //十佳合--选区-- 初始选择的值
      quPickerOptions: ['A区','B区'], //十佳合--选区-- 选项列表
    };
  },
  // computed: {
  //   jiedianMobileNew(){
  //     if (this.jiedianMobileAuto.length !== 11 || isNaN(this.jiedianMobileAuto)) {
  //       if (this.jiedianMobileAuto == '') {
  //         return '请输入'; // 或者 throw new Error('Invalid phone number');
  //       }else {
  //         return this.jiedianMobileAuto; // 或者 throw new Error('Invalid phone number');
  //       }
        
  //     }
      
  //     // 使用slice()方法提取手机号的前3位和后4位，中间用'XXXX'替换
  //     return this.jiedianMobileAuto.slice(0, 3) + 'xxxx' + this.jiedianMobileAuto.slice(7);
  //   }
  // },
  filters: {
    formatPhoneNumber(phoneNumber) {
      // 检查手机号长度是否为11位，如果不是则直接返回原字符串（或者你可以抛出错误）
      // if (phoneNumber.length !== 11 || isNaN(phoneNumber)) {
      //     return phoneNumber; // 或者 throw new Error('Invalid phone number');
      // }
      
      if (phoneNumber.length !== 11 || isNaN(phoneNumber)) {
        if (phoneNumber == '') {
          return '请输入'; // 或者 throw new Error('Invalid phone number');
        }else {
          return phoneNumber; // 或者 throw new Error('Invalid phone number');
        }
        
      }
      
      // 使用slice()方法提取手机号的前3位和后4位，中间用'XXXX'替换
      return phoneNumber.slice(0, 3) + 'xxxx' + phoneNumber.slice(7);
   }
  },
  activated() {
    console.log('active',this.$route.query.mid,'midddddd')
      
    // this.niuniuRegisterPop = true
    // this.uniacid = localStorage.getItem("uniacid") ? localStorage.getItem("uniacid") : ''
    this.uniacid = this.$route.query.i;
    // 换牛二期-88-接点人ID-开始
    if(this.uniacid == '88'){
      this.niuMid = this.$route.query.mid
      
    }
    if(this.uniacid == '89'){
      window.localStorage.setItem("midRegister",this.$route.query.mid)
      // this.getUidNiuniu()
    }
    // 换牛二期-88-接点人ID-结束
    if( this.uniacid =='46'){
      if(!localStorage.getItem("klr_type")) {
        localStorage.setItem("klr_type",1);
      }
      // this.form.klr_type = localStorage.getItem("klr_type")
      this.klr_type = localStorage.getItem("klr_type");
      this.form.klr_type = localStorage.getItem("klr_type") == 2 ? 'B区' : 'A区';
    }
    // if(!localStorage.getItem("klr_type")) {
    //   localStorage.setItem("klr_type",1);
    // }
    // this.form.klr_type = localStorage.getItem("klr_type") == 2 ? 'B区' : 'A区';
    // this.klr_type = localStorage.getItem("klr_type");
    console.log(this.uniacid,'active');
    if (this.pageType == 'register') { //用户注册页面
      this.fun.setWXTitle('用户注册');
      this.registration();
    } else { //用户信息页面
      this.fun.setWXTitle('基本信息');
      this.essentialInformation();
    }
  },
  async mounted() {
    this.uniacid = this.$route.query.i;
    if( this.uniacid =='46'){
      if(!localStorage.getItem("klr_type")) {
        localStorage.setItem("klr_type",1);
      }
      // this.form.klr_type = localStorage.getItem("klr_type")
      this.klr_type = localStorage.getItem("klr_type");
      this.form.klr_type = localStorage.getItem("klr_type") == 2 ? 'B区' : 'A区';
    }

    console.log(this.uniacid,'mounted');
    if (JSON.parse(window.localStorage.getItem("globalParameter")).register_locate == true) {
      this.orderLocationObj = await this.getCurrentOrderLocation();
    }
    if (this.$route.query.pageType) {
      this.pageType = this.$route.query.pageType;
    }
  },
  methods: {
    // 十佳合--选区
    openQu(){
      this.openQuPickerShow = true;
    },
    onCancelQuPicker(){
      this.openQuPickerShow = false;
    },
    onConfirmQuPicker(e){
      this.openQuPickerShow = false;
      this.quPickerSelected = e;
    },
    setUserSlip(uid){
      if(this.quPickerSelected == ''){
        wx.showToast({
          title: '请选择分区',
          icon: 'none'
        })
        return
      }
      var params = {
        uid: uid,
        type: this.quPickerSelected == 'A区' ? 1 : 2,
      }
      console.log(params,'params')
       var that = this;
        $http.post("shijiahe.hualuo",params).then(response => {
            if (response.result == 1) {
                
            }else {
              Toast(response.msg);
            }
            
        });
      
    },
    // 十佳合--选区--结束
    getUidNiuniu(pid){
      $http.get("NiuTwo.auto_user_slip",{
        uid: pid
      }).then(
        response => {
          console.log(response,'response1111')
          if (response.result == 1) {
            this.jiedianSearchId = response.data.jd_uid;
            this.jiedianSearchNum = response.data.jd_num;
            $http.get("NiuTwo.get_user_tel",{
              uid: response.data.jd_uid
            }).then(
              response => {
                console.log(response,'response1111')
                if (response.result == 1) {
                  this.jiedianMobileAuto = response.data;
                  this.jiedianMobile = response.data;
                  $http.get("NiuTwo.get_userid",{
                    mobile: response.data
                  },"加载中").then(
                    response => {
                      console.log(response,'response')
                      if (response.result == 1) {
                        this.jiedianInputId = response.data.uid
                      }else {
                        Toast(response.msg);
                      }
                    },
                    response => {
                      console.log(response.msg);
                    })
                }else {
                  Toast(response.msg);
                }
              },
              response => {
                console.log(response.msg);
              }
            );
          }else {
            Toast(response.msg);
          }
        },
        response => {
          console.log(response.msg);
        }
      );
      // $http.get("NiuTwo.get_uid",{}).then(
      //   response => {
      //     console.log(response,'response')
      //     if (response.result == 1) {
      //       var pid = response.data;
      //       $http.get("NiuTwo.get_user_slip",{
      //         pid: pid
      //       }).then(
      //         response => {
      //           console.log(response,'response1111')
      //           if (response.result == 1) {
      //             this.jiedianSearchId = response.data.jd_uid;
      //             this.jiedianSearchNum = response.data.jd_num;
      //             $http.get("NiuTwo.get_user_tel",{
      //               uid: response.data.jd_uid
      //             }).then(
      //               response => {
      //                 console.log(response,'response1111')
      //                 if (response.result == 1) {
      //                   this.jiedianMobileAuto = response.data;
      //                   this.jiedianMobile = response.data;
      //                   $http.get("NiuTwo.get_userid",{
      //                     mobile: response.data
      //                   },"加载中").then(
      //                     response => {
      //                       console.log(response,'response')
      //                       if (response.result == 1) {
      //                         this.jiedianInputId = response.data.uid
      //                       }else {
      //                         Toast(response.msg);
      //                       }
      //                     },
      //                     response => {
      //                       console.log(response.msg);
      //                     })
      //                 }else {
      //                   Toast(response.msg);
      //                 }
      //               },
      //               response => {
      //                 console.log(response.msg);
      //               }
      //             );
      //           }else {
      //             Toast(response.msg);
      //           }
      //         },
      //         response => {
      //           console.log(response.msg);
      //         }
      //       );
      //     }else {
      //       Toast(response.msg);
      //     }
      //   },
      //   response => {
      //     console.log(response.msg);
      //   }
      // );
    },
    // 牛牛商城-89-切换接点人手机号状态
    changeJiedianMobileinput(){
      this.niuJiedianMobileinput = true;
      this.jiedianMobile = ''
      
      
    },
    // 牛牛商城-89-接点人手机号输入框失焦事件
    jiedianMobileBlur(e){
      console.log(e,'11111111111111111111',this.niuJiedianMobileinput)
      this.niuJiedianMobileinput = false;
      var mobile = e.target.value
      if (this.fun.isTextEmpty(mobile)) {
        // Toast("请填写手机号");
        // this.getUidNiuniu()
        return;
      }

      // var reg = /^1[3456789]\d{9}$/;
			// if (!reg.test(mobile)) {
			// 	// Toast("请填写正确的手机号");
			// 	return false;
			// }
      // console.log('走了么')
      
    },
    // 牛牛商城-89-接点人手机号输入框失焦事件
    jiedianMobileInput(e){
      console.log(e,'jiedianMobileInput')
      // return
      // var reg = /^1[3456789]\d{9}$/;
      var reg = /^1[123456789]\d{9}$/;
			if (!reg.test(e)) {
				// Toast("请填写正确的手机号");
				return false;
			}
      console.log('走了么')
      $http.get("NiuTwo.get_userid",{
        mobile: e
      },"加载中").then(
        response => {
          console.log(response,'response')
          if (response.result == 1) {
            if(response.data){
              this.jiedianInputId = response.data.uid
              this.searchJiedian(response.data.uid)
            }else {
              this.jiedianMobile = this.jiedianMobileAuto;
              this.jiedianInputId = this.jiedianSearchId;
              console.log(this.jiedianSearchId,'this.jiedianSearchId')
            }
            
          }else {
            this.jiedianMobile = this.jiedianMobileAuto;
            this.jiedianInputId = this.jiedianSearchId;
            console.log(this.jiedianSearchId,'this.jiedianSearchId')
            Toast(response.msg);
          }
        },
        response => {
          console.log(response.msg);
        }
      );
    },
    // 牛牛商城-89-查询接点人位置
    searchJiedian(id){
      $http.get("NiuTwo.get_user_slip",{
        pid: id
      }).then(
        response => {
          console.log(response,'response1111')
          if (response.result == 1) {
            this.jiedianSearchId = response.data.jd_uid;
            this.jiedianSearchNum = response.data.jd_num;
          }else {
            Toast(response.msg);
          }
        },
        response => {
          console.log(response.msg);
        }
      );
      
    },
    recomandMobileBlur(e){
      console.log('recomandMobileBlur',e.target.value)
      var mobile = e.target.value
      // if (this.fun.isTextEmpty(mobile)) {
      //   Toast("请填写手机号");
      //   return;
      // }

      // var reg = /^1[3456789]\d{9}$/;
      var reg = /^1[123456789]\d{9}$/;
			if (mobile.length != '' && !reg.test(mobile)) {
				Toast("请填写正确的手机号");
				return false;
			}
      console.log('走了么')
      // $http.get("NiuTwo.get_user",{
      //   tel: mobile
      // },"加载中").then(
      //   response => {
      //     console.log(response,'response')
      //     if (response.result == 1) {
      //       // this.recomandIdNiu = response.msg;
      //       window.localStorage.setItem("midRegister",response.data)
      //       this.getUidNiuniu(response.data)
      //     }else {
      //       Toast(response.msg);
      //       this.recomandMobile = ''
      //       window.localStorage.removeItem("midRegister")
      //     }
      //   },
      //   response => {
      //     console.log(response.msg);
      //   }
      // );

    },
    // 牛牛商城-89-推荐人手机号输入框失焦事件
    recomandMobileInput(e){
      var mobile = e
      if (this.fun.isTextEmpty(mobile)) {
        // Toast("请填写手机号");
        return;
      }

      // var reg = /^1[3456789]\d{9}$/;
      var reg = /^1[123456789]\d{9}$/;
			if (!reg.test(mobile)) {
				// Toast("请填写正确的手机号");
				return false;
			}
      // console.log('走了么')
      $http.get("NiuTwo.get_user",{
        tel: mobile
      },"加载中").then(
        response => {
          console.log(response,'response')
          if (response.result == 1) {
            // this.recomandIdNiu = response.msg;
            window.localStorage.setItem("midRegister",response.data)
            this.getUidNiuniu(response.data)
          }else {
            Toast(response.msg);
            this.recomandMobile = ''
            this.jiedianMobile = ''
            this.jiedianMobileAuto = ''
            this.jiedianInputId = ''
            window.localStorage.removeItem("midRegister")
          }
        },
        response => {
          console.log(response.msg);
        }
      );
    },
    onChange(picker, value, index) {
      console.log('onChange');
      Toast(`当前值：${value}, 当前索引：${index}`);
    },
    onConfirm(value, index) {
      console.log('confirmmmmm');
      // Toast(`当前值：${value}, 当前索引：${index}`);
      console.log(value, index,'value, index');
    },
    onCancel() {
      // Toast('取消');
      this.ewcodeShow = false;
    },
    sexSwitch(e) { //性别切换
      this.sexLIst.forEach((item, index) => {
        if (e == index) {
          let arry = this.sexLIst[index].checked = true;
          this.$set(this.sexLIst[index], index, arry);
          if (e == 1) {
            this.form.sex = 2;
          } else {
            this.form.sex = 1;
          }
        } else {
          let arry = this.sexLIst[index].checked = false;
          this.$set(this.sexLIst[index], index, arry);
        }
      });
    },
    openOpenPlatformAgreement(e) { //弹出用户协议弹窗
      this.openPlatformAgreement = true;
      this.agreementContent(e);
    },

    agreementContent(e) { //获取协议内容
      e == 'user'?this.popoverProtocolContent = this.userProtocol:(e == 'platform'?this.popoverProtocolContent = this.platformAgreement:'');
    },
    //时间选择组件方法
    formatDate(date, type) {
      if (type == "dataTime") {
        return `${date.getYear()+1900}-${date.getMonth() + 1}-${date.getDate()}`;
      } else {
        return `${date.getMonth() + 1}-${date.getDate()}`;
      }
    },

    //头像上传
    afterRead(e) {
      let fd = new FormData();
      fd.append("file", e.file);
      let uploadUrl = this.fun.getRealUrl("upload.uploadPic", {});
      axios
        .post(uploadUrl, fd, {
          headers: {
            "Content-Type": "multipart/form-data"
          }
        })
        .then(response => {
          var responseData = response.data;
          if (responseData.result === 1) {
            this.fileList[0].url = responseData.data.img_url;
            this.form.avatar = responseData.data.img;
            Toast(responseData.msg);
          } else {
            Toast(responseData.msg);
          }
        })
        .catch(error => {
          Toast.clear();
          console.log(error);
        });
    },
    onConfirm(date) { //生日时间选择
      this.birthdayShow = false;
      this.form.birthday = this.formatDate(date, "dataTime");
    },
    dataTimeFiem(date) { //日期时间选择
      this.dateTimeShow = false;
      this.form.dataTime = this.formatDate(date, "dataTime");
    },
    // 城市结果
    resultAdd(district) {
      this.form.address = district;
      this.initDistrict("", district);
    },
    initDistrict(data, district) {
      if (!this.fun.isTextEmpty(data)) {
        if (data.area_name) {
          this.districtName = data.province_name + " " + data.city_name + " " + data.area_name;
        }
        return;
      }

      if (!this.fun.isTextEmpty(district)) {
        this.districtName = district.itemName1 + " " + district.itemName2 + " " + district.itemName3;
      }
    },
    updateInfo() { //更新用户资料
      $http.get("member.logout.index").then(
        response => {
          if (response.result == 1) {
            window.localStorage.setItem("isWxLogin", -1);
            this.$store.commit("savemodel", {});
            localStorage.setItem("token", "");
            localStorage.setItem("loginUid", "");
            window.firstLogin = 0;
            clearLoginData(); // 方法在index.html
            location.reload();
            // this.$dialog
            //   .alert({ message: response.msg })
            //   .then(() => {
            //     location.reload();
            //   })
            //   .catch(() => {});
          }
        },
        response => {
          console.log(response.msg);
        }
      );
    },
    //获取当前位置信息，用于提交订单
    getCurrentOrderLocation() {
      return new Promise((resolev, reject) => {
        Toast.loading({
          message: "获取位置信息",
          forbidClick: true
        });
        var mapObj = new AMap.Map("iCenter");
        mapObj.plugin("AMap.Geolocation", () => {
          var geolocation = new AMap.Geolocation({
            enableHighAccuracy: true, // 是否使用高精度定位，默认:true
            timeout: 10000, // 超过10秒后停止定位，默认：无穷大
            maximumAge: 0, // 定位结果缓存0毫秒，默认：0
            convert: true, // 自动偏移坐标，偏移后的坐标为高德坐标，默认：true
            showButton: true, // 显示定位按钮，默认：true
            buttonPosition: "LB", // 定位按钮停靠位置，默认：'LB'，左下角
            buttonOffset: new AMap.Pixel(10, 20), // 定位按钮与设置的停靠位置的偏移量，默认：Pixel(10, 20)
            showMarker: true, // 定位成功后在定位到的位置显示点标记，默认：true
            showCircle: true, // 定位成功后用圆圈表示定位精度范围，默认：true
            panToLocation: true, // 定位成功后将定位到的位置作为地图中心点，默认：true
            zoomToAccuracy: true // 定位成功后调整地图视野范围使定位位置及精度范围视野内可见，默认：false
          });
          mapObj.addControl(geolocation);
          geolocation.getCurrentPosition();
          AMap.event.addListener(geolocation, "complete", obj => {
            Toast.clear();
            //console.log("执行1");
            resolev({
              positioning_success: 1,
              register_province: obj.addressComponent.province,
              register_city: obj.addressComponent.city
            });
          }); // 返回定位信息
          AMap.event.addListener(geolocation, "error", () => {
            Toast.clear();
            //console.log("执行2");
            resolev({
              positioning_success: 0,
              register_province: "",
              register_city: ""
            });
          }); // 返回定位出错信息
        });
      });
    },
    essentialInformation() { //基本信息页数据
      $http.get("member.member-info.user-info", {
        basic_info: 1
      }).then(
        response => {
          if (response.result == 1) {
            this.form.nickname = response.data.nickname;
            this.form.avatar = response.data.avatar;
            this.fileList[0].url = response.data.avatar_image;
            this.diyform = response.data.diy_form;
            this.nameOfTheMall = response.data.name;
            // this.userProtocol = response.data.agreement
            this.changeNickname = response.data?.can_update_nickname;
            this.diyField = response.data?.diy_field;

            // zmh 优家修改
            console.log(this.diyField.form,'this.diyField.formthis.diyField.form');
            const currentIndex = this.diyField.form.findIndex(item => item.name === '身份证号');
            console.log(currentIndex,'currentIndex');
            if(currentIndex!=-1){
              this.newIdcardNum = this.diyField.form[currentIndex].value;
            }
            this.fixedDiyField = response.data?.fixed_diy_field;
            this.changePicture = response.data?.can_update_avatar;
            response.data.basic_info.forEach((item, index) => {
              this.registerBasicInfo[item.field] = item;
            });
            this.form.name = this.registerBasicInfo?.name?.value;
            this.form.sex = this.registerBasicInfo?.gender?.value;
            if(this.registerBasicInfo?.birthday?.value?.birthyear != ""){ //生日赋值
              this.form.birthday = this.registerBasicInfo?.birthday?.value?.birthyear + '-' + this.registerBasicInfo
                ?.birthday?.value?.birthmonth + '-' + this.registerBasicInfo?.birthday?.value?.birthday;
              this.currentDate = new Date(this.registerBasicInfo?.birthday?.value?.birthyear,this.registerBasicInfo
                ?.birthday?.value?.birthmonth-1, this.registerBasicInfo?.birthday?.value?.birthday);
            }
            if(this.registerBasicInfo.address?.value?.province_name != ""){ //地址赋值
              this.districtName = this.registerBasicInfo.address?.value?.province_name + '  ' + this.registerBasicInfo
                ?.address?.value?.city_name + '  ' + this.registerBasicInfo?.address?.value?.area_name;
            }
            this.form.address = this.registerBasicInfo?.address?.value;
            this.form.detailedAddress = this.registerBasicInfo?.address?.value.address;
            this.diyStatus = response.data?.diy_form.status;
            if(this.fixedDiyField.length>0 && this.fixedDiyField[0].value != ''){
              this.fixedFieldModification = true;
            }
            if (this.registerBasicInfo.gender.value == 1) { //性别赋值
              this.sexLIst[0].checked = true;
              this.sexLIst[1].checked = false;
            }else if(this.registerBasicInfo.gender.value == 2){
              this.sexLIst[0].checked = false;
              this.sexLIst[1].checked = true;
            }
            if (this.fixedDiyField.length > 0) {
              this.form.field = response.data.fixed_diy_field[0].value;
            }
          } else {
            this.$dialog.alert({
              message: response.msg
            });
          }
        },
        response => {
          console.log(response.msg);
        }
      );
    },
    registration() { //获取注册页数据
      $http.get("member.register.register-page", {
        basic_info: 1
      }).then(
        response => {
          if (response.result == 1) {
            // localStorage.setItem("uniacid",response.basic_info.home.item.ViewSet.extension.uniacid)
            // console.log(localStorage.getItem("uniacid"),'localStorage.getItem("uniacid")')
            // this.uniacid = localStorage.getItem("uniacid") ? localStorage.getItem("uniacid") : ''
            localStorage.setItem("uniacid",this.uniacid);
            if(response.data.status && response.data.status == 'redirec' && response.data.url){
              // 处理后台开启微信授权登录，但是直接点击注册页面链接进去，可以进行注册
              // 修改为：进入后授权登录，登录后跳转接口返回的手机号
              window.location.href = response.data.url;
              return;
            }
            this.dataList = response.data;
            let basic_info = JSON.parse(localStorage.getItem("yz_basic_info"));
            this.inputShowList['captchaShow'] = response.data.get_captcha?.captcha?.status == '1' ? true : false;
            this.inputShowList['passwordInputShow'] = response.data.is_password == '1' ? true : false;
            this.inputShowList['countryCodeShow'] = response.data.getInviteCode?.json?.country_code == '1' ? true :
              false;
            this.inputShowList['logPlugIn'] = basic_info?.plugin_setting?.account_login?.enable == 1?true:false;
            this.fixedDiyField = response.data.fixed_diy_field;
            this.invite = response.data.getInviteCode?.json;
            this.diyform = response.data.diy_form;
            this.nameOfTheMall = response.data.name;
            this.userProtocol = response.data.agreement;
            this.platformAgreement = response.data.platform_agreement;
            this.diyField = response.data.diy_field;
            this.diyStatus = response.data.diy_form.status;
            this.form.login_checked = response.data.agreement?.default_tick;
            this.enable_btn = basic_info?.plugin_setting?.account_login?.enable;
            this.form.login_checked = response.data.agreement?.default_tick == 1?true:false; //默认勾选
            if (this.enable_btn == 1) { //如果后台开了账号登录插件
              this.inputShowList['passwordInputShow'] = true;
            }
            if(!this.fun.isTextEmpty(this.invite.invitation_code)){ //判断是否为邀请二维码进入
              this.form.invite_code = this.invite.invitation_code.invite_code;
            }else{
              if (this.invite.status == 1) {
                this.form.invite_code = this.invite.default_invite;
              }
            }
            response.data.register_basic_info.forEach((item, index) => {
              console.log(item,'item')
              this.registerBasicInfo[item.field] = item;
            }); 
          } else {
            this.$dialog.alert({
              message: response.msg
            });
          }
        },
        response => {
          console.log(response.msg);
        }
      );
    },
    registerOpenPop(){
      let that = this;

      if (this.fun.isTextEmpty(this.$refs.input_list.form.mobile) && !this.inputShowList.logPlugIn) {
        Toast("请填写手机号");
        return;
      }


      if (this.$refs.input_list.form.country == "86" && this.fun.isMoblie(this.$refs.input_list.form.mobile) && !this.inputShowList.logPlugIn) {
        Toast("请填写正确的手机号");
        return;
      }
      if (this.fun.isTextEmpty(this.$refs.input_list.form.code) && !this.inputShowList.logPlugIn && this.uniacid != '70') {
        Toast("请填写验证码");
        return;
      }

      if (this.fun.isTextEmpty(this.$refs.input_list.form.account) && this.inputShowList.logPlugIn) {
        Toast("请填写账号");
        return;
      }

      if (this.$refs.input_list.form.account.length < 6 && this.inputShowList.logPlugIn) {
        Toast("账号必须不低于六位数");
        return;
      }

      if (this.fun.isTextEmpty(this.$refs.input_list.form.password) && this.inputShowList.passwordInputShow) {
        Toast("请填写密码");
        return;
      }
      if (this.$refs.input_list.form.password.length < 6 && this.inputShowList.passwordInputShow) {
        Toast("密码必须不低于六位数");
        return;
      }

      if (this.fun.isTextEmpty(this.form.invite_code) && this.invite.status == 1 && this.invite.required == 1) {
        Toast("请填写邀请码");
        return;
      }

      if (this.inputShowList.logPlugIn && this.fun.isTextEmpty(this.form.fathername)) {
        Toast("请填写父亲姓名");
        return;
      }

      if (this.inputShowList.logPlugIn && this.fun.isTextEmpty(this.form.mothername)) {
        Toast("请填写母亲姓名");
        return;
      }

      if (this.registerBasicInfo.name && this.registerBasicInfo.name.show && this.registerBasicInfo.name.must == 1 &&
        this.fun.isTextEmpty(this.form.name)) {
        Toast("请填写姓名");
        return;
      }
      if (this.registerBasicInfo.gender && this.registerBasicInfo.gender.show && this.registerBasicInfo.gender.must ==
        1 && this.fun.isTextEmpty(this.form.sex)) {
        Toast("请选择性别");
        return;
      }

      if (this.registerBasicInfo.birthday && this.registerBasicInfo.birthday.show && this.registerBasicInfo.birthday
        .must == 1 && this.fun.isTextEmpty(this.form.birthday)) {
        Toast("请选择生日");
        return;
      }

      if (this.registerBasicInfo.address && this.registerBasicInfo.address.show && this.registerBasicInfo.address
        .must == 1 && this.fun.isTextEmpty(this.districtName)) {
        Toast("请填写地址");
        return;
      }
      if (this.fixedDiyField.length > 0) {
        let status = true;
        let msg = '';
        this.fixedDiyField.forEach((item, index) => {
          if (this.fun.isTextEmpty(this.form.field) && item.must == 1) {
            msg = item.name;
            status = false;
          }
        });
        if (!status) {
          Toast("请填写" + msg);
          return;
        }
      }
      if (!this.fun.isTextEmpty(this.diyField) && this.diyField?.form.length > 0 && this.diyField?.form_open == 1) {
        let status = true;
        let msg = '';
        this.diyField.form.forEach((item, index) => {
          if (this.fun.isTextEmpty(item.value)) {
            msg = item.name;
            status = false;
          }
        });
        if (!status) {
          Toast("请填写" + msg);
          return;
        }
      }

      //判断协议是否勾选
      let protocolState = '';
      if(this.userProtocol.status == 1 ||  this.platformAgreement.status == 1){
        protocolState = true;
      }
      if(protocolState && !this.form.login_checked){
        Toast("请勾选协议");
        return;
      }

      if (this.diyStatus == 1) {
        let success_diyform = this.$refs.gofunarr.validation();
        if (!this.$refs.gofunarr.isValidation) {
          return;
        }
      }
      this.registerShow = true;
      let url = 'member.register.Prompt';
      $http.post(url, {}, '').then(
        response => {
          if (response.result == 1) {
            console.log(response.data,'hahhahahahahah');
            this.registerNotice = response.data;
          }
        }
      );
    },
    confirmRegister(){
      this.registerShow = false;
      this.register();
    },
    // 谷昕雨70 查看上下级获取邀请码
    getInviteCode(data){
      console.log(data,'data')
      this.form.invite_code = data;
    },
    // 换牛二期-88-提交注册
    registerHuanniu(){
      let that = this;
      console.log(that.uniacid ,'注册uniacid');
      if (this.fun.isTextEmpty(this.$refs.input_list.form.mobile) && !this.inputShowList.logPlugIn) {
        Toast("请填写手机号");
        return;
      }


      if (this.$refs.input_list.form.country == "86" && this.fun.isMoblie(this.$refs.input_list.form.mobile) && !this.inputShowList.logPlugIn) {
        Toast("请填写正确的手机号");
        return;
      }

      if (this.fun.isTextEmpty(this.$refs.input_list.form.code) && !this.inputShowList.logPlugIn && this.uniacid != '54'  && this.uniacid != '70' && this.uniacid != '95' && uniacid != '121') {
        Toast("请填写验证码");
        return;
      }

      if (this.fun.isTextEmpty(this.$refs.input_list.form.account) && this.inputShowList.logPlugIn) {
        Toast("请填写账号");
        return;
      }

      if (this.$refs.input_list.form.account.length < 6 && this.inputShowList.logPlugIn) {
        Toast("账号必须不低于六位数");
        return;
      }

      if (this.fun.isTextEmpty(this.$refs.input_list.form.password) && this.inputShowList.passwordInputShow) {
        Toast("请填写密码");
        return;
      }
      if (this.$refs.input_list.form.password.length < 6 && this.inputShowList.passwordInputShow) {
        Toast("密码必须不低于六位数");
        return;
      }

      if (this.fun.isTextEmpty(this.form.invite_code) && this.invite.status == 1 && this.invite.required == 1) {
        Toast("请填写邀请码");
        return;
      }

      if (this.inputShowList.logPlugIn && this.fun.isTextEmpty(this.form.fathername)) {
        Toast("请填写父亲姓名");
        return;
      }

      if (this.inputShowList.logPlugIn && this.fun.isTextEmpty(this.form.mothername)) {
        Toast("请填写母亲姓名");
        return;
      }

      if (this.registerBasicInfo.name && this.registerBasicInfo.name.show && this.registerBasicInfo.name.must == 1 &&
        this.fun.isTextEmpty(this.form.name)) {
        Toast("请填写姓名");
        return;
      }
      if (this.registerBasicInfo.gender && this.registerBasicInfo.gender.show && this.registerBasicInfo.gender.must ==
        1 && this.fun.isTextEmpty(this.form.sex)) {
        Toast("请选择性别");
        return;
      }

      if (this.registerBasicInfo.birthday && this.registerBasicInfo.birthday.show && this.registerBasicInfo.birthday
        .must == 1 && this.fun.isTextEmpty(this.form.birthday)) {
        Toast("请选择生日");
        return;
      }

      if (this.registerBasicInfo.address && this.registerBasicInfo.address.show && this.registerBasicInfo.address
        .must == 1 && this.fun.isTextEmpty(this.districtName)) {
        Toast("请填写地址");
        return;
      }
      
      if (this.fixedDiyField.length > 0) {
        let status = true;
        let msg = '';
        this.fixedDiyField.forEach((item, index) => {
          if (this.fun.isTextEmpty(this.form.field) && item.must == 1) {
            msg = item.name;
            status = false;
          }
        });
        if (!status) {
          Toast("请填写" + msg);
          return;
        }
      }
      if (!this.fun.isTextEmpty(this.diyField) && this.diyField?.form.length > 0 && this.diyField?.form_open == 1) {
        let status = true;
        let msg = '';
        this.diyField.form.forEach((item, index) => {
          if (this.fun.isTextEmpty(item.value)) {
            msg = item.name;
            status = false;
          }
        });
        if (!status) {
          Toast("请填写" + msg);
          return;
        }
      }

      //判断协议是否勾选
      let protocolState = '';
      if(this.userProtocol.status == 1 ||  this.platformAgreement.status == 1){
        protocolState = true;
      }
      if(protocolState && !this.form.login_checked){
        Toast("请勾选协议");
        return;
      }

      if (this.diyStatus == 1) {
        let success_diyform = this.$refs.gofunarr.validation();
        if (!this.$refs.gofunarr.isValidation) {
          return;
        }
      }
      let json;
      if(that.uniacid == '46' && that.klr_type){
        json = {
          mobile: this.$refs.input_list.form.mobile,
          password: this.$refs.input_list.form.password,
          code: this.$refs.input_list.form.code,
          account: this.$refs.input_list.form.account,
          invite_code: this.form.invite_code,
          name: this.form.name,
          birthday: this.form.birthday,
          custom_value: this.form.field,
          positioning_success: this.orderLocationObj.positioning_success,
          klr_type: this.klr_type
        };
      }else {
        json = {
          mobile: this.$refs.input_list.form.mobile,
          password: this.$refs.input_list.form.password,
          code: this.$refs.input_list.form.code,
          account: this.$refs.input_list.form.account,
          invite_code: this.form.invite_code,
          name: this.form.name,
          birthday: this.form.birthday,
          custom_value: this.form.field,
          positioning_success: this.orderLocationObj.positioning_success
        };
      }


      // let json = {
      //   mobile: this.$refs.input_list.form.mobile,
      //   password: this.$refs.input_list.form.password,
      //   code: this.$refs.input_list.form.code,
      //   account: this.$refs.input_list.form.account,
      //   invite_code: this.form.invite_code,
      //   name: this.form.name,
      //   birthday: this.form.birthday,
      //   custom_value: this.form.field,
      //   positioning_success: this.orderLocationObj.positioning_success,
      //   // klr_type: this.form.klr_type
      // }

      if(this.registerBasicInfo.gender && this.registerBasicInfo.gender.show){
        json['gender'] = this.form.sex;
      }
      //地址处理
      if (this.registerBasicInfo.address.show && this.form.address != '') {
        json['address'] = this.addressToDealWith(this.form);
      }


      //自定义字段加值
      if (!this.fun.isTextEmpty(this.diyField) && this.diyField.form.length > 0) {
        let json1 = {};
        this.diyField.form.forEach((item, index) => {
          json1[item.field] = item.value;
        });
        json['customDatas'] = json1;
      }

      //会员标签-记录会员用什么设备注册
      let system_type = this.fun.getTyep();
      if (system_type == 1) {
        json['system_type'] = 'wechat';
      } else if (system_type == 7) {
        json['system_type'] = 'app';
      } else if (system_type == 8) {
        json['system_type'] = 'ali';
      } else if (system_type == 5 && this.fun.isPc()) {
        json['system_type'] = 'pc';
      } else if (system_type == 5 && !this.fun.isPc()) {
        json['system_type'] = 'h5';
      }

      let url = '';
      if (this.inputShowList.logPlugIn) {
        json['fathername'] = this.form.fathername;
        json['mothername'] = this.form.mothername;
        url = 'plugin.account-login.frotend.member.register';
      } else {
        url = 'member.register.register';
      }

      $http.post(url, json, '提交中').then(
        response => {
          if (response.result == 1) {
            let query = {};
            let isAppCoinK = this.$route.query.CoinK || false;//是否来着第三方app的跳转
            if(isAppCoinK) query.CoinK = 1;

            this.member_id = response.data.uid;
            this.$store.commit("savemodel", response.data);
            this.$dialog.alert({
              message: "注册成功",
              callback: () => {
              }
            });
            console.log(this.uniacid,'成灌灌灌灌孤寡孤寡孤寡嘎嘎嘎');
            // this.$dialog.alert({
            //   message: 'uniacid' + this.uniacid,
            //   callback: () => {
            //   }
            // });
            if(this.uniacid==6){
              window.location.href = 'https://fenfa.axu9.com/25jprt';
            }else if(this.uniacid==5){
              console.log('66666666666');
              window.location.href = 'https://fenfa.axu9.com/kjevxy';
            }
            console.log(this.fun.isTextEmpty(this.diyStatus),this.diyStatus,'2222222222222222');
            if (this.fun.isTextEmpty(this.diyStatus)) {
              that.$router.push(this.fun.getUrl("login",{},query));
            } else if (this.diyStatus == 1) {
              //去提交diy
              this.$refs.gofunarr.submit();
              this.$router.push(this.fun.getUrl("login",{},query));
            }
            // if (this.fun.isTextEmpty(this.diyStatus)) {
            //   that.$router.push(this.fun.getUrl("login",{},query));
            // } else if (this.diyStatus == 1) {
            //   //去提交diy
            //   this.$refs.gofunarr.submit();
            //   this.$router.push(this.fun.getUrl("login",{},query));
            // }
          } else {
            this.$dialog.alert({
              message: response.msg
            });
          }
        },
        response => {
          console.log(response.msg);
        }
      );
    },
    // 换牛二期-88-校验账号
    validateAccount(account) {
       // 校验账号长度是否为6位
      if (account.length !== 6) {
        return false;
      }

      // 正则表达式：匹配纯数字
      const regex = /^\d+$/;

      // 测试账号是否符合正则表达式
      return regex.test(account);
    },
    // 牛牛商城-89-校验手机号
    validateMobile(mobile) {
      // 校验账号长度是否为6位
    //  if (mobile.length !== 13) {
    //    return false;
    //  }
     const regex = /^1[3456789]\d{9}$/;

     // 测试账号是否符合正则表达式
     return regex.test(mobile);
   },
  //  牛牛商城-89-关闭注册提交弹窗
   cancelPop(){
    this.niuniuRegisterPop = false
   },
    //  牛牛商城-89-注册会员滑落
    userSlip(uid){
      $http.post("NiuTwo.user_slip",{
        uid: uid,
        pid: this.jiedianSearchId,
        num: this.jiedianSearchNum
      }).then(
        response => {
          console.log(response,'response')
          if (response.result == 1) {
            this.jiedianSearchId = '';
            this.jiedianSearchNum = '';
            this.jiedianMobile = '';
            this.recomandMobile = '';
            this.jiedianMobile = '';
            this.jiedianMobileAuto = '';
            this.$refs.input_list.form  = {}
          }else {
            Toast(response.msg);
          }
        },
        response => {
          console.log(response.msg);
        }
      );
    },
    // 牛牛商城-89-注册前校验
    verReisterNiu(){
      let that = this;
      console.log(that.uniacid ,'注册uniacid');
      if (this.fun.isTextEmpty(this.$refs.input_list.form.mobile) && !this.inputShowList.logPlugIn) {
        Toast("请填写手机号");
        return;
      }


      if (this.$refs.input_list.form.country == "86" && this.fun.isMoblie(this.$refs.input_list.form.mobile) && !this.inputShowList.logPlugIn) {
        Toast("请填写正确的手机号");
        return;
      }

      if (this.fun.isTextEmpty(this.$refs.input_list.form.code) && !this.inputShowList.logPlugIn) {
        Toast("请填写验证码");
        return;
      }

      if (this.fun.isTextEmpty(this.$refs.input_list.form.account) && this.inputShowList.logPlugIn) {
        Toast("请填写账号");
        return;
      }

      if (this.$refs.input_list.form.account.length < 6 && this.inputShowList.logPlugIn) {
        Toast("账号必须不低于六位数");
        return;
      }

      if (this.fun.isTextEmpty(this.$refs.input_list.form.password) && this.inputShowList.passwordInputShow) {
        Toast("请填写密码");
        return;
      }
      if (this.$refs.input_list.form.password.length < 6 && this.inputShowList.passwordInputShow) {
        Toast("密码必须不低于六位数");
        return;
      }

      if (this.fun.isTextEmpty(this.form.invite_code) && this.invite.status == 1 && this.invite.required == 1) {
        Toast("请填写邀请码");
        return;
      }

      if (this.inputShowList.logPlugIn && this.fun.isTextEmpty(this.form.fathername)) {
        Toast("请填写父亲姓名");
        return;
      }

      if (this.inputShowList.logPlugIn && this.fun.isTextEmpty(this.form.mothername)) {
        Toast("请填写母亲姓名");
        return;
      }

      if (this.registerBasicInfo.name && this.registerBasicInfo.name.show && this.registerBasicInfo.name.must == 1 &&
        this.fun.isTextEmpty(this.form.name)) {
        Toast("请填写姓名");
        return;
      }
      if (this.registerBasicInfo.gender && this.registerBasicInfo.gender.show && this.registerBasicInfo.gender.must ==
        1 && this.fun.isTextEmpty(this.form.sex)) {
        Toast("请选择性别");
        return;
      }

      if (this.registerBasicInfo.birthday && this.registerBasicInfo.birthday.show && this.registerBasicInfo.birthday
        .must == 1 && this.fun.isTextEmpty(this.form.birthday)) {
        Toast("请选择生日");
        return;
      }

      if (this.registerBasicInfo.address && this.registerBasicInfo.address.show && this.registerBasicInfo.address
        .must == 1 && this.fun.isTextEmpty(this.districtName)) {
        Toast("请填写地址");
        return;
      }
      if (this.fixedDiyField.length > 0) {
        let status = true;
        let msg = '';
        this.fixedDiyField.forEach((item, index) => {
          if (this.fun.isTextEmpty(this.form.field) && item.must == 1) {
            msg = item.name;
            status = false;
          }
        });
        if (!status) {
          Toast("请填写" + msg);
          return;
        }
      }
      if (!this.fun.isTextEmpty(this.diyField) && this.diyField?.form.length > 0 && this.diyField?.form_open == 1) {
        let status = true;
        let msg = '';
        this.diyField.form.forEach((item, index) => {
          if (this.fun.isTextEmpty(item.value)) {
            msg = item.name;
            status = false;
          }
        });
        if (!status) {
          Toast("请填写" + msg);
          return;
        }
      }
      // 推荐人手机号
      if (this.fun.isTextEmpty(this.recomandMobile) && !this.inputShowList.logPlugIn) {
        Toast("请填写推荐人手机号");
        return;
      }
     
      // 接点人手机号
      if (this.fun.isTextEmpty(this.jiedianMobile) && !this.inputShowList.logPlugIn) {
        Toast("接点人手机号不能为空");
        return;
      }
       if (!this.validateMobile(this.recomandMobile) && !this.inputShowList.logPlugIn) {
        Toast("推荐人手机号格式错误");
        return;
      }
      //  if (!this.validateMobile(this.jiedianMobile) && !this.inputShowList.logPlugIn) {
      //   Toast("接点人手机号格式错误");
      //   return;
      // }

      //判断协议是否勾选
      let protocolState = '';
      if(this.userProtocol.status == 1 ||  this.platformAgreement.status == 1){
        protocolState = true;
      }
      if(protocolState && !this.form.login_checked){
        Toast("请勾选协议");
        return;
      }

      if (this.diyStatus == 1) {
        let success_diyform = this.$refs.gofunarr.validation();
        if (!this.$refs.gofunarr.isValidation) {
          return;
        }
      }
      // if((this.jiedianMobileAuto != this.jiedianMobileAuto) && (this.jiedianSearchId != this.jiedianInputId)){
      //   Toast("接点人信息不正确");
      //   return
      // }
      if(this.jiedianSearchId != this.jiedianInputId){
        Toast("接点人信息不正确");
        return
      }
      console.log(this.pageType,'牛牛商城---按钮状态')
      if(this.pageType == 'register'){
        console.log(window.localStorage.getItem("midRegister"),this.jiedianSearchId,this.jiedianInputId,'this.jiedianInputId')
        // this.niuniuRegisterPop = true;
        $http.post("NiuTwo.guanxi", {
          t_id: window.localStorage.getItem("midRegister"),
          j_id: this.jiedianSearchId
        }, '提交中').then(
          response => {
            if (response.result == 1) {
              this.niuniuRegisterPop = true;
             
            } else {
              this.$dialog.alert({
                message: response.msg
              });
            }
          },
          response => {
            console.log(response.msg);
          }
        );
        return
      }
    },
    // 牛牛商城- 89-注册
    registerNiuniu() { //提交注册
      var that = this;
      let json;
        json = {
          mobile: this.$refs.input_list.form.mobile,
          password: this.$refs.input_list.form.password,
          code: this.$refs.input_list.form.code,
          account: this.$refs.input_list.form.account,
          invite_code: this.form.invite_code,
          name: this.form.name,
          birthday: this.form.birthday,
          custom_value: this.form.field,
          positioning_success: this.orderLocationObj.positioning_success,
          // recomandMobile: this.recomandMobile,//推荐人手机号
          // jiedianMobile: this.jiedianMobile,//接点人手机号
          // recomandId: this.recomandIdNiu,
        };
      if(this.registerBasicInfo.gender && this.registerBasicInfo.gender.show){
        json['gender'] = this.form.sex;
      }
      //地址处理
      if (this.registerBasicInfo.address.show && this.form.address != '') {
        json['address'] = this.addressToDealWith(this.form);
      }


      //自定义字段加值
      if (!this.fun.isTextEmpty(this.diyField) && this.diyField.form.length > 0) {
        let json1 = {};
        this.diyField.form.forEach((item, index) => {
          json1[item.field] = item.value;
        });
        json['customDatas'] = json1;
      }

      //会员标签-记录会员用什么设备注册
      let system_type = this.fun.getTyep();
      if (system_type == 1) {
        json['system_type'] = 'wechat';
      } else if (system_type == 7) {
        json['system_type'] = 'app';
      } else if (system_type == 8) {
        json['system_type'] = 'ali';
      } else if (system_type == 5 && this.fun.isPc()) {
        json['system_type'] = 'pc';
      } else if (system_type == 5 && !this.fun.isPc()) {
        json['system_type'] = 'h5';
      }

      let url = '';
      if (this.inputShowList.logPlugIn) {
        json['fathername'] = this.form.fathername;
        json['mothername'] = this.form.mothername;
        url = 'plugin.account-login.frotend.member.register';
      } else {
        url = 'member.register.register';
      }

      $http.post(url, json, '提交中').then(
        response => {
          if (response.result == 1) {
            if(this.pageType == 'register'){
              this.niuniuRegisterPop = false;
              this.userSlip(response.data.uid)
              
            }
            console.log('走了么1111111111111111')
            let query = {};
            let isAppCoinK = this.$route.query.CoinK || false;//是否来着第三方app的跳转
            if(isAppCoinK) query.CoinK = 1;

            this.member_id = response.data.uid;
            this.$store.commit("savemodel", response.data);
            this.$dialog.alert({
              message: "注册成功",
              callback: () => {
              }
            });
            console.log(this.uniacid,'成灌灌灌灌孤寡孤寡孤寡嘎嘎嘎');
           
            console.log(this.fun.isTextEmpty(this.diyStatus),this.diyStatus,'2222222222222222');
            if (this.fun.isTextEmpty(this.diyStatus)) {
              that.$router.push(this.fun.getUrl("login",{},query));
            } else if (this.diyStatus == 1) {
              //去提交diy
              this.$refs.gofunarr.submit();
              this.$router.push(this.fun.getUrl("login",{},query));
            }
          } else {
            this.$dialog.alert({
              message: response.msg
            });
          }
        },
        response => {
          console.log(response.msg);
          this.niuniuRegisterPop = false
        }
      );
    },
    register() { //提交注册
      let that = this;
      console.log(that.uniacid ,'注册uniacid');
      if (this.fun.isTextEmpty(this.$refs.input_list.form.mobile) && !this.inputShowList.logPlugIn) {
        Toast("请填写手机号");
        return;
      }


      if (this.$refs.input_list.form.country == "86" && this.fun.isMoblie(this.$refs.input_list.form.mobile) && !this.inputShowList.logPlugIn) {
        Toast("请填写正确的手机号");
        return;
      }

      if (this.fun.isTextEmpty(this.$refs.input_list.form.code) && !this.inputShowList.logPlugIn && this.uniacid != '54'  && this.uniacid != '70' && this.uniacid != '95' && this.uniacid != '121' && this.uniacid != '128') {
        Toast("请填写验证码");
        return;
      }
      if (this.$refs.input_list.form.mobile.length<11 && !this.inputShowList.logPlugIn) {
        Toast("请填写正确的手机号");
        return;
      }

      if (this.fun.isTextEmpty(this.$refs.input_list.form.account) && this.inputShowList.logPlugIn) {
        Toast("请填写账号");
        return;
      }

      if (this.$refs.input_list.form.account.length < 6 && this.inputShowList.logPlugIn) {
        Toast("账号必须不低于六位数");
        return;
      }

      if (this.fun.isTextEmpty(this.$refs.input_list.form.password) && this.inputShowList.passwordInputShow) {
        Toast("请填写密码");
        return;
      }
      if (this.$refs.input_list.form.password.length < 6 && this.inputShowList.passwordInputShow) {
        Toast("密码必须不低于六位数");
        return;
      }

      if (this.fun.isTextEmpty(this.form.invite_code) && this.invite.status == 1 && this.invite.required == 1) {
        Toast("请填写邀请码");
        return;
      }

      if (this.inputShowList.logPlugIn && this.fun.isTextEmpty(this.form.fathername)) {
        Toast("请填写父亲姓名");
        return;
      }

      if (this.inputShowList.logPlugIn && this.fun.isTextEmpty(this.form.mothername)) {
        Toast("请填写母亲姓名");
        return;
      }

      if (this.registerBasicInfo.name && this.registerBasicInfo.name.show && this.registerBasicInfo.name.must == 1 &&
        this.fun.isTextEmpty(this.form.name)) {
        Toast("请填写姓名");
        return;
      }
      if (this.registerBasicInfo.gender && this.registerBasicInfo.gender.show && this.registerBasicInfo.gender.must ==
        1 && this.fun.isTextEmpty(this.form.sex)) {
        Toast("请选择性别");
        return;
      }

      if (this.registerBasicInfo.birthday && this.registerBasicInfo.birthday.show && this.registerBasicInfo.birthday
        .must == 1 && this.fun.isTextEmpty(this.form.birthday)) {
        Toast("请选择生日");
        return;
      }

      if (this.registerBasicInfo.address && this.registerBasicInfo.address.show && this.registerBasicInfo.address
        .must == 1 && this.fun.isTextEmpty(this.districtName)) {
        Toast("请填写地址");
        return;
      }
      if (this.fixedDiyField.length > 0) {
        let status = true;
        let msg = '';
        this.fixedDiyField.forEach((item, index) => {
          if (this.fun.isTextEmpty(this.form.field) && item.must == 1) {
            msg = item.name;
            status = false;
          }
        });
        if (!status) {
          Toast("请填写" + msg);
          return;
        }
      }
      if (!this.fun.isTextEmpty(this.diyField) && this.diyField?.form.length > 0 && this.diyField?.form_open == 1) {
        let status = true;
        let msg = '';
        this.diyField.form.forEach((item, index) => {
          if (this.fun.isTextEmpty(item.value)) {
            msg = item.name;
            status = false;
          }
        });
        if (!status) {
          Toast("请填写" + msg);
          return;
        }
      }
      // 验证账号
      if (this.fun.isTextEmpty(this.$refs.input_list.form.login_name) && !this.inputShowList.logPlugIn && this.uniacid == '88') {
        Toast("请填写账号");
        return;
      }
      if (!this.validateAccount(this.$refs.input_list.form.login_name) && !this.inputShowList.logPlugIn && this.uniacid == '88') {
        Toast("您的账号错误请重新上传");
        return;
      }
      
      // 验证导师id
      if (this.fun.isTextEmpty(this.$refs.input_list.form.daoshi_id) && !this.inputShowList.logPlugIn && this.uniacid == '88') {
        Toast("请填写导师id");
        return;
      }
      //// 验证分区--十佳合注册滑落
      // if (this.fun.isTextEmpty(this.quPickerSelected) && this.uniacid == '128') {
      //   Toast("请选择分区");
      //   return;
      // }

      //判断协议是否勾选
      let protocolState = '';
      if(this.userProtocol.status == 1 ||  this.platformAgreement.status == 1){
        protocolState = true;
      }
      if(protocolState && !this.form.login_checked){
        Toast("请勾选协议");
        return;
      }

      if (this.diyStatus == 1) {
        let success_diyform = this.$refs.gofunarr.validation();
        if (!this.$refs.gofunarr.isValidation) {
          return;
        }
      }
      let json;
      if(that.uniacid == '46' && that.klr_type){
        json = {
          mobile: this.$refs.input_list.form.mobile,
          password: this.$refs.input_list.form.password,
          code: this.$refs.input_list.form.code,
          account: this.$refs.input_list.form.account,
          invite_code: this.form.invite_code,
          name: this.form.name,
          birthday: this.form.birthday,
          custom_value: this.form.field,
          positioning_success: this.orderLocationObj.positioning_success,
          klr_type: this.klr_type
        };
      }else if(that.uniacid == '88'){
        localStorage.setItem('mid',this.recomandId)
        json = {
          mobile: this.$refs.input_list.form.mobile,
          password: this.$refs.input_list.form.password,
          code: this.$refs.input_list.form.code,
          account: this.$refs.input_list.form.account,
          invite_code: this.form.invite_code,
          name: this.form.name,
          birthday: this.form.birthday,
          custom_value: this.form.field,
          positioning_success: this.orderLocationObj.positioning_success,
          login_name: this.$refs.input_list.form.login_name,
          daoshi_id: this.$refs.input_list.form.daoshi_id,
          pid: this.recomandId == '' ? this.niuMid :  this.recomandId
        };
      }else {
        json = {
          mobile: this.$refs.input_list.form.mobile,
          password: this.$refs.input_list.form.password,
          code: this.$refs.input_list.form.code,
          account: this.$refs.input_list.form.account,
          invite_code: this.form.invite_code,
          name: this.form.name,
          birthday: this.form.birthday,
          custom_value: this.form.field,
          positioning_success: this.orderLocationObj.positioning_success
        };
      }


      // let json = {
      //   mobile: this.$refs.input_list.form.mobile,
      //   password: this.$refs.input_list.form.password,
      //   code: this.$refs.input_list.form.code,
      //   account: this.$refs.input_list.form.account,
      //   invite_code: this.form.invite_code,
      //   name: this.form.name,
      //   birthday: this.form.birthday,
      //   custom_value: this.form.field,
      //   positioning_success: this.orderLocationObj.positioning_success,
      //   // klr_type: this.form.klr_type
      // }

      if(this.registerBasicInfo.gender && this.registerBasicInfo.gender.show){
        json['gender'] = this.form.sex;
      }
      //地址处理
      if (this.registerBasicInfo.address.show && this.form.address != '') {
        json['address'] = this.addressToDealWith(this.form);
      }


      //自定义字段加值
      if (!this.fun.isTextEmpty(this.diyField) && this.diyField.form.length > 0) {
        let json1 = {};
        this.diyField.form.forEach((item, index) => {
          json1[item.field] = item.value;
        });
        json['customDatas'] = json1;
      }

      //会员标签-记录会员用什么设备注册
      let system_type = this.fun.getTyep();
      if (system_type == 1) {
        json['system_type'] = 'wechat';
      } else if (system_type == 7) {
        json['system_type'] = 'app';
      } else if (system_type == 8) {
        json['system_type'] = 'ali';
      } else if (system_type == 5 && this.fun.isPc()) {
        json['system_type'] = 'pc';
      } else if (system_type == 5 && !this.fun.isPc()) {
        json['system_type'] = 'h5';
      }

      let url = '';
      if (this.inputShowList.logPlugIn) {
        json['fathername'] = this.form.fathername;
        json['mothername'] = this.form.mothername;
        url = 'plugin.account-login.frotend.member.register';
      } else {
        url = 'member.register.register';
      }
      $http.post(url, json, '提交中').then(
        response => {
          if (response.result == 1) {
            let query = {};
            let isAppCoinK = this.$route.query.CoinK || false;//是否来着第三方app的跳转
            if(isAppCoinK) query.CoinK = 1;

            this.member_id = response.data.uid;
            this.$store.commit("savemodel", response.data);
            if(this.uniacid!='95'){
              this.$dialog.alert({
                message: "注册成功",
                callback: () => {
                }
              });
            }
            // if(this.uniacid=='128'){
            // this.setUserSlip(response.data.uid);
            // }
            
           
            if(this.uniacid==6){
              window.location.href = 'https://fenfa.axu9.com/25jprt';
            }else if(this.uniacid==5){
              console.log('66666666666');
              window.location.href = 'https://fenfa.axu9.com/kjevxy';
            }else if(this.uniacid==95){
              this.$dialog.confirm({
                message: `注册成功,没有APP?去下载`
              })
              .then(() => {
                console.log('下载')
                window.location.href = 'https://www.pgyer.com/onrn8O6i';
              })
              .catch(() => {
                console.log('取消')
              });
            }
            console.log(this.fun.isTextEmpty(this.diyStatus),this.diyStatus,'2222222222222222');
            if (this.fun.isTextEmpty(this.diyStatus)) {
              that.$router.push(this.fun.getUrl("login",{},query));
            } else if (this.diyStatus == 1) {
              //去提交diy
              this.$refs.gofunarr.submit();
              this.$router.push(this.fun.getUrl("login",{},query));
            }
            // if (this.fun.isTextEmpty(this.diyStatus)) {
            //   that.$router.push(this.fun.getUrl("login",{},query));
            // } else if (this.diyStatus == 1) {
            //   //去提交diy
            //   this.$refs.gofunarr.submit();
            //   this.$router.push(this.fun.getUrl("login",{},query));
            // }
          } else {
            this.$dialog.alert({
              message: response.msg
            });
          }
        },
        response => {
          console.log(response.msg);
        }
      );
    },
    modifyingUserInformation() { //提交用户信息修改
      if (this.registerBasicInfo.name && this.registerBasicInfo.name.show && this.registerBasicInfo.name.must == 1 &&
        this.fun.isTextEmpty(this.form.name)) {
        Toast("请填写姓名");
        return;
      }
      if (this.registerBasicInfo.gender && this.registerBasicInfo.gender.show && this.registerBasicInfo.gender.must ==
        1 && this.fun.isTextEmpty(this.form.sex)) {
        Toast("请选择性别");
        return;
      }
      if (this.registerBasicInfo.birthday && this.registerBasicInfo.birthday.show && this.registerBasicInfo.birthday
        .must == 1 && this.fun.isTextEmpty(this.form.birthday)) {
        Toast("请选择生日");
        return;
      }
      if (this.registerBasicInfo.address && this.registerBasicInfo.address.show && this.registerBasicInfo.address
        .must == 1 && this.fun.isTextEmpty(this.districtName)) {
        Toast("请填写地址");
        return;
      }

      if (this.fixedDiyField.length > 0) {
        let status = true;
        let msg = '';
        this.fixedDiyField.forEach((item, index) => {
          if (this.fun.isTextEmpty(this.form.field) && item.must == 1) {
            msg = item.name;
            status = false;
          }
        });
        if (!status) {
          Toast("请填写" + msg);
          return;
        }
      }
      if (!this.fun.isTextEmpty(this.diyField) && this.diyField?.form.length > 0 && this.diyField?.form_open == 1) {
        let status = true;
        let msg = '';
        this.diyField.form.forEach((item, index) => {
          if (this.fun.isTextEmpty(item.value)) {
            msg = item.name;
            status = false;
          }
        });
        if (!status) {
          Toast("请填写" + msg);
          return;
        }
      }

      if (this.diyStatus == 1) {
        let success_diyform = this.$refs.gofunarr.validation();
        if (!this.$refs.gofunarr.isValidation) {
          return;
        }
      }
      
      
      let json = {
          avatar: this.form.avatar,
          nickname: this.form.nickname,
          name: this.form.name,
          birthday: this.form.birthday,
          custom_value: this.form.field,
        };

      if(this.registerBasicInfo.gender && this.registerBasicInfo.gender.show){
        json['gender'] = this.form.sex;
      }

      //地址处理
      if (!this.fun.isTextEmpty(this.form.address.province) && !this.fun.isTextEmpty(this.form.address
        .city)) { //如果有回显直接传回显的地址
        this.form.address.address = this.form.detailedAddress;
        json['address'] = this.form.address;
      } else { //重新选择地址
        if (this.registerBasicInfo.address.show && this.form.address != '') {
          json['address'] = this.addressToDealWith(this.form);
        }
      }

      //自定义字段加值
      if (!this.fun.isTextEmpty(this.diyField) && this.diyField.form.length > 0) {
        let json1 = {};
        this.diyField.form.forEach((item, index) => {
          json1[item.field] = item.value;
        });
        json['customDatas'] = json1;
      }
      let that = this;

      $http.post('member.member-info.user-info-save', json, '正在提交数据...').then(
        response => {
          if (response.result == 1) {
            if (that.fun.isTextEmpty(that.diyStatus)) {
              that.$dialog.alert({
                message: response.msg
              });
              that.$router.go(-1);
            } else if (that.diyStatus == 1) {
              //去提交diy
              that.$dialog.alert({
                message: response.msg
              });
              that.$refs.gofunarr.submit();
              that.$router.go(-1);
            }
          } else {
            that.$dialog.alert({
              message: response.msg
            });
          }
        },
        response => {
          that.$dialog.alert({
            message: response.msg
          });
        }
      );
    },
    addressToDealWith(value) { //地址处理
      let addressJson = {};
      addressJson['province'] = value.address.itemValue1;
      addressJson['city'] = value.address.itemValue2;
      addressJson['area'] = value.address.itemValue3;
      addressJson['province_name'] = value.address.itemName1;
      addressJson['city_name'] = value.address.itemName2;
      addressJson['area_name'] = value.address.itemName3;
      addressJson['address'] = value.detailedAddress;
      return addressJson;
    },

    postDiy(e, member_id = this.member_id) {
      var that = this;
      var formData = e;

      let json = {
        form_data: formData,
        form_id: this.diyform.id,
        member_id: member_id,
        form_type: "register"
      };
      $http.post("plugin.diyform.api.diy-form.save-diy-form-data", json, "提交中...").then(
        response => {
          if (response.result == 1) {} else {
            this.$dialog.alert({
              message: response.msg
            });
          }
        },
        response => {
          this.$dialog.alert({
            message: response.msg
          });
        }
      );
    }
  },
  components: {
    cTitle,
    inputList,
    diyorm
  }
};
